saveToString

abstract suspend fun saveToString(blocks: List<DesignBlock>, allowedResourceSchemes: List<String> = listOf("bundle", "file", "http", "https")): String

Saves the given blocks to a proprietary string. If given the root of a block hierarchy, e.g. a page with multiple children, the entire hierarchy is saved. If a resource uri of any block in that hierarchy has a scheme that is not in allowedResourceSchemes, an exception will be thrown. Note: All given block handles must be valid, otherwise an exception will be thrown.

Performs an internal update to lay out pending changes before the save.

While a font loads, its text is laid out with another font. When the text's size follows its content, blocks saved before the font arrives can differ from blocks saved after it. To compare two saves, first call engine.block.forceLoadResources(blocks).

The source set entries that the engine makes are buffer:// resources that only this engine holds. The save leaves them out, even when the allowed resource schemes hold "buffer", and each fill keeps them.

A page slice has no children, so the blocks that it owns on its page are saved as its children. A page slice on a page among blocks makes the update run also while features/implicitUpdatesEnabled is off. A block among blocks is saved once, as a block of its own. A block that a page slice owns is saved with its Percent position and size in design units. The copy does not follow the size of its page.

Return

a string representation of the blocks.

Parameters

blocks

the blocks to save.

allowedResourceSchemes

the list of allowed resource schemes in the scene.


abstract suspend fun saveToString(blocks: List<DesignBlock>, allowedResourceSchemes: List<String> = listOf("bundle", "file", "http", "https"), onDisallowedResourceScheme: suspend (uri: Uri, dataHash: String) -> Uri): String

Saves the given blocks to a proprietary string, as saveToString does, and passes each resource URI whose scheme is not in allowedResourceSchemes to onDisallowedResourceScheme instead of throwing. Note: All given block handles must be valid, otherwise an exception will be thrown.

Performs an internal update to lay out pending changes before the save. Cancelling the coroutine stops the save and the callbacks that still run.

The source set entries that the engine makes are buffer:// resources that only this engine holds. onDisallowedResourceScheme gets each of them, whatever allowedResourceSchemes holds. The save leaves out each entry that the callback did not move to another address, and each fill keeps them.

Return

a string representation of the blocks.

Parameters

blocks

the blocks to save.

allowedResourceSchemes

the list of allowed resource schemes in the scene.

onDisallowedResourceScheme

called on the engine thread for each resource URI with a scheme absent from allowedResourceSchemes, with the URI and the hash of the resource's data. It returns the URI that the saved blocks use for the resource, or the URI it got when the resource needs no other address. The save waits for each answer. When the callback throws, the save fails with an EngineException of code EngineErrorCode.BINDING_HOST_CALLBACK_THREW.